/*
 * Copyright 2013 JROSE
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jrose.api.config;

import lombok.Data;

import java.io.Serializable;

@Data
public class DataSourceConfig implements Serializable {
    private static final long serialVersionUID = 169932290584488555L;

    // 通用配置信息
    private String driverClass;                             // JDBC驱动类名
    private String jdbcUrl;                                 // JDBC URL
    private String username;                                // 数据库连接用户名
    private String password;                                // 数据库连接密码

    // BoneCP相关配置信息
    private int partitionCount = 3;                         // 分区数量
    private int minConnectionsPerPartition = 4;             // 每个分区含有的最小连接数
    private int maxConnectionsPerPartition = 20;            // 每个分区含有的最大连接数
    private int acquireIncrement = 2;                       // 每次新增连接的数量
    private int poolAvailabilityThreshold = 20;             // 连接池阀值，当(可用连接/最大连接<连接阀值)时，创建新的连接
    private int connectionTimeoutInMs = 20000;              // 连接超时时间阀值，获取连接时，超出阀值时间，则获取失败，毫秒为单位
    private int releaseHelperThreads = 3;                   // 连接池助手线程数量，可设置为0，该参数会降低运行速度，但程序有大量连接时，有助于提升高并发程序的性能
    private int statementReleaseHelperThreads = 1;          // 语句助手线程数，可设置为0，该参数会降低运行速度，但程序有大量的查询语句时，有助于提升高并发程序的性能
    private int idleConnectionTestPeriodInMinutes = 2;      // 测试连接有效性的间隔时间，单位分钟
    private int idleMaxAgeInMinutes = 5;                    // 连接的空闲存活时间，当连接空闲时间大于该阀值时，清除该连接
    private int statementsCacheSize = 1000;                 // 语句缓存个数，默认是0
    private String connectionTestStatement = "SELECT 1";    // SQL statement to use for keep-alive/test of connection
}
